//
//  PopoverLanguageSelect.m
//  X-Touch2
//
//  Created by shengchao yang on 12-3-21.
//  Copyright (c) 2012年 foxhis. All rights reserved.
//

#import "PopoverLanguageSelect.h"
#import "LanguageSelectCell.h"

@implementation PopoverLanguageSelect

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}
-(void) dealloc{
    MyNSLog(@"PopoverLanguageSelect is deallocing...");
    [super dealloc];
}
#pragma mark - tableview datasource
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {    
    return AppSession.langsArray.count;
}
//自定义row
-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CellIdentifier";
	LanguageSelectCell *cell = (LanguageSelectCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
	if (cell == nil){
		cell = [[[LanguageSelectCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
	}
    cell.selectionStyle = UITableViewCellSelectionStyleBlue;//设置选择cell时，没有任何背景颜色
    [cell setData:[AppSession.langsArray objectAtIndex:indexPath.row]];    
    return cell;
}
#pragma mark - tableview datadelegate
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (AppSession.popController.popoverVisible) {
        [AppSession.popController dismissPopoverAnimated:NO];
    }
    AppSession.language = (NSString *)[AppSession.langsArray objectAtIndex:indexPath.row];
    MyNSLog(@"language = %@",AppSession.language);
    postN(@"SysMsg_MenuBookChoose_refreshUI");
    postN(@"SysMsg_GuestCommendView_refreshCommendView");
    postN(@"SysMsg_GuestNineModeView_refreshGuestNineModeView");
    postN(@"SysMsg_MyOrderTableModeView_refreshMyOrderTable");
    postN(@"SysMsg_MyOrderNineModeView_refreshNineMode");
}

#pragma mark - View lifecycle
@end
